package com.crm.controller.system;

import com.crm.pojo.Transform;
import com.crm.result.Result;
import com.crm.service.ReportService;
import com.crm.service.system.HomePageService;
import com.crm.vo.BusinessChangeVO;

import com.crm.vo.HomePage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apiguardian.api.API;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@RestController
@Slf4j
@Api(tags = "首页")
public class HomePageController {
    @Autowired
    private HomePageService homePageService;
    @Autowired
    private ReportService reportService;

    @GetMapping("/index")
    public Result<HomePage>  getInfo(
          @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate beginCreateTime,
          @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate  endCreateTime
    ){
        HomePage homePage=homePageService.getInfo(beginCreateTime,endCreateTime);
        return Result.success(homePage);
    }
    /**
     * 漏斗
     */
    @GetMapping("/report/getVulnerabilityMap/{beginCreateTime}/{endCreateTime}")
    public Result<Transform> getTransform(
            @PathVariable String beginCreateTime,
            @PathVariable String endCreateTime
    ){
     Transform transform = homePageService.getTransform(beginCreateTime,endCreateTime);
     return Result.success(transform);

    }
    /**
     *  商机转龙虎榜
     */
    @ApiOperation("商机转龙虎榜")
    @GetMapping("/index/businessChangeStatistics")
    public Result businessChangeStatistics(
           String beginCreateTime,
           String  endCreateTime

    ){
        List<BusinessChangeVO> list = reportService.businessChangeStatistics(beginCreateTime,endCreateTime);

        return Result.success(list);
    }
    /**
     * 线索转龙虎榜
     */


    @GetMapping("/index/salesStatistic")
    public Result salesStatistic(
            String beginCreateTime,
            String  endCreateTime

    ){
        List<BusinessChangeVO> list = reportService.salesStatistic(beginCreateTime,endCreateTime);

        return Result.success(list);
    }



}
